this.BX=this.BX||{};(function(e,t){"use strict";var a=function(){function e(t,a,i,r){babelHelpers.classCallCheck(this,e);this.domNode=t;this.progressBar=Number(i)>100?100:i;this.progressBg=null;this.number=null;this.fixCounter=r.fixCounter?r.fixCounter:null;this.color1=r.color1;this.color2=r.color2;this.x=0;this.flat=400;this.speed=3;this.rate=0;this.wave=35;this.distance=200}babelHelpers.createClass(e,[{key:"createCanvas",value:function e(){this.canvas=t.Dom.create("canvas",{attrs:{className:"ui-graph-circle-canvas"}});return this.canvas}},{key:"createNumberBlock",value:function e(){this.number=t.Dom.create("div",{attrs:{className:"ui-graph-circle-number","data-progress":this.progressBar}});return this.number}},{key:"drawCircle",value:function e(t,a,i){t.mozImageSmoothingEnabled=false;t.imageSmoothingEnabled=false;t.beginPath();t.arc(a/2,a/2,a/2-1,0,2*Math.PI);t.strokeStyle=i;t.stroke();t.beginPath();t.arc(a/2,a/2,a/2-2,0,2*Math.PI);t.clip()}},{key:"drawSin",value:function e(t,a,i,r,s,n){t.mozImageSmoothingEnabled=false;t.imageSmoothingEnabled=false;t.save();t.beginPath();t.moveTo(0,a);t.lineTo(0,n);t.quadraticCurveTo(a/4,n-a*(s/200),a/2,n);t.lineTo(a/2,n);t.quadraticCurveTo(a*3/4,n+a*(s/200),a,n);t.lineTo(a,a);t.lineTo(0,a);t.fillStyle=i;t.fill();t.restore()}},{key:"init",value:function e(t){var a=this.canvas;a.style.height=t;a.width=a.height=t;var i=document.createElement("canvas"),r=i.getContext("2d");i.width=t;i.height=t;var s=document.createElement("canvas"),n=s.getContext("2d");s.width=t;s.height=t;var h=this.x;var o=this.flat;var l=this.speed;var c=this.rate;var u=this.wave;var m=this.distance;var g=a.getContext("2d");if(!this.color1&&!this.color2){this.drawSin(r,t,"rgba(183, 235, 129, .45)","rgba(183, 235, 129, .45)",u,t-t*c);this.drawSin(n,t,"rgba(178, 232, 0, .29)","rgba(178, 232, 0, .29)",u,t-t*c)}else{this.drawSin(r,t,this.color1,this.color1,u,t-t*c);this.drawSin(n,t,this.color2,this.color2,u,t-t*c)}function p(){g.clearRect(0,0,t,t);g.drawImage(i,h,0,t+o,t);g.drawImage(i,h-t-o,0,t+o,t);g.drawImage(s,h-m,0,t+o,t);g.drawImage(s,h-t-m-o,0,t+o,t);h>=t-l+o?h=0:h+=l;requestAnimationFrame(p)}p()}},{key:"animateWavesBlock",value:function e(t){this.progress=this.progressBar;if(t){if(this.progress<=50){this.rate=.45}if(this.progress>50){this.rate=.75}this.progressBar<=25?this.rate=.25:null}else{if(this.progress<=50){this.rate=.5}if(this.progress>50){this.rate=.85}}this.progressBar<=25?this.progress=25:null}},{key:"createWrapper",value:function e(){this.graph=t.Dom.create("div",{attrs:{className:"ui-graph-circle-wrapper"}});t.Dom.append(this.createCanvas(),this.graph);t.Dom.append(this.createNumberBlock(),this.graph);return this.graph}},{key:"addWrapperClass",value:function e(){t.Dom.addClass(this.graph,"ui-graph-circle-wrapper-animate");if(this.fixCounter){t.Dom.addClass(this.graph,"ui-graph-circle-counter")}}},{key:"animateNumber",value:function e(a){var i=this.progressBar;if(a){i=a}if(Number(i)<=0){if(a){this.number.innerHTML="0"}else{this.number.innerHTML="0"+" <span>%</span>"}return}if(a){this.number.innerHTML=a;this.number.innerHTML.length>=4?t.Dom.addClass(this.graph,"ui-graph-font-sm"):null}else{var r=0;var s=1e3/i;var n=setInterval(function(){r++;this.number.innerHTML=r+" <span>%</span>";r===Number(i)?clearInterval(n):null}.bind(this),s)}}},{key:"updateCounter",value:function e(t,a){this.progressBar=t;if(a){this.animateNumber(a);this.animateWavesBlock(a)}else{this.animateNumber();this.animateWavesBlock()}}},{key:"show",value:function e(){t.Dom.append(this.createWrapper(),this.domNode);setTimeout(function(){this.addWrapperClass();this.animateNumber(this.fixCounter);this.animateWavesBlock(this.fixCounter);this.init(200)}.bind(this),500)}}]);return e}();e.UiCircle=a})(this.BX.UI=this.BX.UI||{},BX);
//# sourceMappingURL=ui.circle.bundle.map.js